home *** CD-ROM | disk | FTP | other *** search
- // Copyright (C) 1997-2002 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- //
- // Alias|Wavefront Script File
- // MODIFY THIS AT YOUR OWN RISK
- //
- // Creation Date: 9 June 1998
- // Author: js
- //
- //
- // Procedure Name:
- // dynConnectToTime
- //
- // Description:
- //
- // For each selected particle or emitter object, if that object's
- // current time attribute has no incoming connection,
- // this action makes a connection from time1.outTime.
- // This action is useful when you have duplicated a particle or emitter
- // object without duplicating connections, or in some other
- // way broken the object's input to current time,
- // and you want to re-establish the default input from time1.
- //
- //
- // Input Arguments:
- // None.
- //
- // Return Value:
- // None.
- //
-
-
- proc connectObjectToTime( string $objName )
- //
- // Connect the object's currentTime attribute to time1.
- // Objects must have a "current time" attribute.
- {
- // Is there a connection into currentTime?
- // Get list of connected plugs, see if
- // node name + "currentTime" is in the list.
- //
- string $currTimePlug = $objName + ".currentTime";
-
- string $conn[] = `listConnections -p true -c true $objName`;
-
- int $i;
- int $connectionExists = 0;
- string $connectedTo = "";
- for ( $i= 0; $i < size($conn); $i++)
- {
- // If one of the connected plugs is the current time
- // plug, then a connection exists and we are not
- // supposed to make one.
- //
- if ($conn[ $i ] == $currTimePlug)
- {
- $connectionExists = 1;
- $connectedTo = $conn[$i + 1];
- break;
- }
- }
-
- // If no connection into currentTime was found, make one now
- //
- if ($connectionExists == 0)
- {
- string $cmd = "connectAttr time1.outTime " + $currTimePlug;
- evalEcho $cmd;
- }
- else
- {
- warning($objName + ".currentTime is already connected to " + $connectedTo + ".");
- if ($connectedTo != "time1.outTime")
- {
- warning("Please break this connection, and try to connect to time1.outTime again.");
- }
- }
- }
-
-
-
- global proc dynConnectToTime()
- //
- // Get the list of selected objects, get all particle shapes or emitters which are
- // selected or are children of selected transforms, and call connectObjectToTime
- // to make the connection for each.
- {
- // Get the full selection list.
- //
- string $list[] = `ls -sl`;
- int $i;
- for ($i = 0; $i < size($list); $i++)
- {
- // if this is a particle shape or emitter, make the connection
- //
- if ( (`nodeType $list[$i]` == "particle") ||
- (`nodeType $list[$i]` == "fluidEmitter") ||
- (`nodeType $list[$i]` == "pointEmitter") )
- {
- connectObjectToTime( $list[$i] );
- }
- else
- {
- // Otherwise, walk through its children.
- // Add to list any particle shapes we find.
- //
- string $childList[] = `listRelatives -s $list[$i]`;
- int $j;
- for ($j = 0; $j < size($childList); $j++)
- {
- if ((`nodeType $childList[$j]` == "particle") ||
- (`nodeType $childList[$j]` == "fluidEmitter") ||
- (`nodeType $childList[$j]` == "pointEmitter"))
- {
- connectObjectToTime( $childList[$j] );
- }
- else
- {
- warning($childList[$j] + " is not a particle or emitter; only particles and emitters can be connected to currentTime");
- }
- }
- }
- }
- }
-
-